package com.itheima.dao;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author benben278
 * @create 2022-03-15 10:35
 */
@Mapper
public interface OrderSettingDao {
    //新增
    @Insert("insert into t_ordersetting (orderDate,number,reservations) values (#{orderDate},#{number},#{reservations})")
    void add(OrderSetting orderSetting);
    //根据日期更新预约人数
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);
    //根据预约日期查询
    @Select("select count(*) from t_ordersetting where orderDate = #{orderDate}")
    long findCountByOrderDate(Date orderDate);
    //根据年月查询当月预约设置信息
    @Select("select * from t_ordersetting where orderDate between #{begin} and #{end}")
    List<OrderSetting> getOrderSettingByMonth(Map<String, String> map);
    //根据日期查询预约设置信息
    @Select("select * from t_ordersetting where orderDate = #{orderDate}")
    OrderSetting findByOrderDate(Date parseString2Date);
    //根据预约日期更新已预约人数
    @Update("update t_ordersetting set reservations = #{reservations} where orderDate = #{orderDate}")
    void editReservationsByOrderDate(OrderSetting orderSetting);
}
